home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / c / qtools0.2-src.lha / src / libqtools / TDDD.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-07-18  |  9.6 KB  |  518 lines

  1. #ifndef    TDDD_H
  2. #define    TDDD_H
  3. /*
  4.  * iff
  5.  */
  6.  
  7. struct IFFheader {
  8.   int form;
  9.   int size;
  10.   int type;
  11. };
  12.  
  13. struct IFFchunk {
  14.   int type;
  15.   int size;
  16.   struct IFFchunk *next;
  17.   struct IFFchunk *iter;
  18.   void *data;
  19. };
  20.  
  21. struct IFFdescriptor {
  22.   char *name;
  23. };
  24.  
  25. /* IFF-identifier */
  26. #define ID_FORM MKID('F','O','R','M')
  27.  
  28. /* TDDD-identifier */
  29. #define ID_TDDD MKID('T','D','D','D')
  30.  
  31. /* main-chunks of TDDD */
  32. #define ID_OBJ  MKID('O','B','J',' ')
  33.  
  34. /* sub-chunks of OBJ */
  35. #define ID_DESC MKID('D','E','S','C')
  36. #define ID_TOBJ MKID('T','O','B','J')
  37.  
  38. /* sub-sub-chunks of DESC */
  39. #define ID_SHAP MKID('S','H','A','P')
  40. #define ID_SHP2 MKID('S','H','P','2')
  41. #define ID_POSI MKID('P','O','S','I')
  42. #define ID_AXIS MKID('A','X','I','S')
  43. #define ID_SIZE MKID('S','I','Z','E')
  44. #define ID_PNTS MKID('P','N','T','S')
  45. #define ID_PNT2 MKID('P','N','T','2')
  46. #define ID_EDGE MKID('E','D','G','E')
  47. #define ID_EDG2 MKID('E','D','G','2')
  48. #define ID_FACE MKID('F','A','C','E')
  49. #define ID_FAC  MKID('F','A','C','\0')
  50. #define ID_BBOX MKID('B','B','O','X')
  51.  
  52. #define ID_NAME MKID('N','A','M','E')
  53. #define ID_COLR MKID('C','O','L','R')
  54. #define ID_REFL MKID('R','E','F','L')
  55. #define ID_TRAN MKID('T','R','A','N')
  56. #define ID_SPC1 MKID('S','P','C','1')
  57. #define ID_SPC2 MKID('S','P','C','2')
  58. #define ID_INT1 MKID('I','N','T','1')
  59. #define ID_CLST MKID('C','L','S','T')
  60. #define ID_CLS2 MKID('C','L','S','2')
  61. #define ID_RLST MKID('R','L','S','T')
  62. #define ID_RLS2 MKID('R','L','S','2')
  63. #define ID_TLST MKID('T','L','S','T')
  64. #define ID_TLS2 MKID('T','L','S','2')
  65. #define ID_EFLG MKID('E','F','L','G')
  66. #define ID_EFL2 MKID('E','F','L','2')
  67. #define ID_PRP1 MKID('P','R','P','1')
  68. #define ID_PRP2 MKID('P','R','P','2')
  69. #define ID_FOGL MKID('F','O','G','L')
  70. #define ID_FOG2 MKID('F','O','G','2')
  71. #define ID_FOG3 MKID('F','O','G','3')
  72. #define ID_BLB2 MKID('B','L','B','2')
  73. #define ID_PART MKID('P','A','R','T')
  74. #define ID_PAR2 MKID('P','A','R','2')
  75. #define ID_PTFN MKID('P','T','F','N')
  76. #define ID_FGRP MKID('F','G','R','P')
  77. #define ID_FGR2 MKID('F','G','R','2')
  78. #define ID_FGR3 MKID('F','G','R','3')
  79. #define ID_FGR4 MKID('F','G','R','4')
  80. #define ID_BBSG MKID('B','B','S','G')
  81. #define ID_SBSG MKID('S','B','S','G')
  82. #define ID_TXT1 MKID('T','X','T','1')
  83. #define ID_TXT2 MKID('T','X','T','2')
  84. #define ID_TXT3 MKID('T','X','T','3')
  85. #define ID_TXT4 MKID('T','X','T','4')
  86. #define ID_BRS1 MKID('B','R','S','1')
  87. #define ID_BRS2 MKID('B','R','S','2')
  88. #define ID_BRS3 MKID('B','R','S','3')
  89. #define ID_BRS4 MKID('B','R','S','4')
  90. #define ID_BRS5 MKID('B','R','S','5')
  91.  
  92. #define ID_DTOO MKID('D','T','O','O')
  93. #define ID_PTHD MKID('P','T','H','D')
  94. #define ID_PTH2 MKID('P','T','H','2')
  95. #define ID_PTH3 MKID('P','T','H','3')
  96. #define ID_FORD MKID('F','O','R','D')
  97. #define ID_FOR2 MKID('F','O','R','2')
  98. #define ID_FOR3 MKID('F','O','R','3')
  99. #define ID_ANID MKID('A','N','I','D')
  100.  
  101. #define ID_STND MKID('S','T','N','D')
  102. #define ID_STID MKID('S','T','I','D')
  103. #define ID_STDT MKID('S','T','D','T')
  104.  
  105. /*
  106.  * datatypes
  107.  */
  108. typedef signed int fract;
  109.  
  110. typedef struct {
  111.   unsigned char r, g, b;
  112. } rgb;
  113.  
  114. typedef struct {
  115.   fract x;
  116.   fract y;
  117.   fract z;
  118. } vector;
  119.  
  120. typedef struct {
  121.   vector a;
  122.   vector b;
  123.   vector c;
  124. } matrix;
  125.  
  126. typedef struct {
  127.   vector pos;
  128.   vector xaxis;
  129.   vector yaxis;
  130.   vector zaxis;
  131.   vector size;
  132. } tform;
  133.  
  134. /*
  135.  * structures
  136.  */
  137.  
  138. /* defines for SHAP/SHP2 shape */
  139. #define SH_SPHERE    0
  140. #define SH_STENCI    1
  141. #define SH_AXIS        2
  142. #define SH_FACETS    3
  143. #define SH_SURFAC    4
  144. #define SH_GROUND    5
  145.  
  146. /* defines for SHAP lamp */
  147. #define LP_TYPE    0b000011
  148. #define LP_NOLAMP    0
  149. #define LP_SUN    1
  150. #define LP_FALL    2
  151. #define LP_SHADOW    0b000100
  152. #define LP_SHDWOF    0
  153. #define LP_SHDWON    4
  154. #define LP_FORM    0b011000
  155. #define LP_SPHERE    0
  156. #define LP_CYLIND    8
  157. #define LP_CONICA    16
  158.  
  159. /* defines for SHP2 lamp */
  160. #define LP2_TYPE    0x0003                    /* 0b00000000000000011 */
  161. #define LP2_NOLAM    0
  162. #define LP2_POINT    1
  163. #define LP2_PARAL    2
  164. #define LP2_SHAPE    0x000C                    /*0b00000000000001100 */
  165. #define LP2_NOSHP    0
  166. #define LP2_ROUND    8
  167. #define LP2_RECTE    12
  168. #define LP2_LENSF    0x0010                    /*0b00000000000010000 */
  169. #define LP2_NORMA    0
  170. #define LP2_NOLEN    16
  171. #define LP2_FALLO    0x0060                    /*0b00000000001100000 */
  172. #define LP2_NOFAL    0
  173. #define LP2_1RFAL    32
  174. #define LP2_CONTR    64
  175. #define LP2_1R2FA    96
  176. #define LP2_SHADO    0x0080                    /*0b00000000010000000 */
  177. #define LP2_SHDOF    0
  178. #define LP2_SHDON    128
  179. #define LP2_SOFTS    0x0100                    /*0b00000000100000000 */
  180. #define LP2_SSOFF    0
  181. #define LP2_SSON    256
  182. #define LP2_BRIGH    0x4000                    /*0b01000000000000000 */
  183. #define LP2_BROFF    0
  184. #define LP2_BRON    32768
  185.  
  186. struct shap {
  187.   unsigned short int shape, lamp;
  188. };
  189.  
  190. struct posi {
  191.   vector position;
  192. };
  193.  
  194. struct axis {
  195.   vector xaxis, yaxis, zaxis;
  196. };
  197.  
  198. struct size {
  199.   vector size;
  200. };
  201.  
  202. struct points {
  203.   unsigned short int pcount;
  204.   vector points[0];
  205. };
  206.  
  207. struct edges {
  208.   unsigned short int ecount;
  209.   unsigned short int edges[0][2];
  210. };
  211.  
  212. struct faces {
  213.   unsigned short int tcount;
  214.   unsigned short int connects[0][3];
  215. };
  216.  
  217. struct bbox {
  218.   vector mins, maxs;
  219. };
  220.  
  221. struct name {
  222.   char name[18];
  223. };
  224.  
  225. struct colr {
  226.   int color;
  227. };
  228.  
  229. struct refl {
  230.   int reflection;
  231. };
  232.  
  233. struct tran {
  234.   int transparency;
  235. };
  236.  
  237. struct spc1 {
  238.   int specular;
  239.   /*char pad; */
  240.   /*rgb color; */
  241. };
  242.  
  243. struct spc2 {
  244.   char pad;
  245.   rgb color;
  246.   fract overdrive;
  247. };
  248.  
  249. struct int1 {
  250.   vector intensity;
  251. };
  252.  
  253. struct faceattr {
  254.   unsigned short int count;
  255.   rgb attr[0];
  256. };
  257.  
  258. #define EDG_FLAGS    0b011000000
  259. #define EDG_QUICK    0b001000000
  260. #define EDG_SHARP    0b010000000
  261.  
  262. struct edgeflags {
  263.   unsigned short int count;
  264.   char flags;
  265. };
  266.  
  267. struct props {
  268.   char dither, hard, rough, shiny, index, quick, phong, genlock;
  269. };
  270.  
  271. struct props2 {
  272.   char bright, hard, rough, shiny, index, quick, phong, genlock;
  273. };
  274.  
  275. struct fog {
  276.   fract length;
  277. };
  278.  
  279. #define FG_TYPE    0b00000000000000011
  280. #define FG_NOFALL    0
  281. #define FG_RAFALL    1
  282. #define FG_AXFALL    2
  283. #define FG_PLFALL    3
  284. #define FG_AXIS    0b00000000000001100
  285. #define FG_XAXIS    0
  286. #define FG_YAXIS    4
  287. #define FG_ZAXIS    8
  288. #define FG_HOTC    0b00000000010000000
  289. #define FG_HOTOFF    0
  290. #define FG_HOTON    128
  291.  
  292. struct fog2 {
  293.   fract length, falloff, hot;
  294.   unsigned short int type;
  295. };
  296.  
  297. struct fog3 {
  298.   fract length, falloff, hot, overdrive;
  299.   unsigned short int type;
  300. };
  301.  
  302. struct blob {
  303.   fract strength, threshold;
  304.   unsigned short int meshdensity;
  305. };
  306.  
  307. #define PRT_TYPE    0b00000000000001111
  308. #define PRT_NOPRT    0
  309. #define PRT_TETRA    1
  310. #define PRT_PYRAM    2
  311. #define PRT_OCTAH    3
  312. #define PRT_CUBES    4
  313. #define PRT_BLOCK    5
  314. #define PRT_DODEC    6
  315. #define PRT_SPHER    7
  316. #define PRT_CENT    0b00000000011110000
  317. #define PRT_INSCR    0
  318. #define PRT_CIRCU    16
  319. #define PRT_INTER    32
  320. #define PRT_BARYC    48
  321. #define PRT_SIZE    0b00000111100000000
  322. #define PRT_SMALL    0
  323. #define PRT_LARGE    256
  324. #define PRT_RANDO    512
  325. #define PRT_SPECI    768
  326. #define PRT_ALIGN    0b01111000000000000
  327. #define PRT_0
  328. #define PRT_4096
  329. #define PRT_8192
  330.  
  331. struct particle {
  332.   unsigned short int type;
  333.   fract size;
  334. };
  335.  
  336. struct particle2 {
  337.   unsigned int type;
  338.   fract part;
  339. };
  340.  
  341. struct particlename {
  342.   char count;
  343.   char name[0];
  344. };
  345.  
  346. struct facesubgroup {
  347.   unsigned short int count;
  348.   char name[18];
  349.   unsigned short int facelist[0];
  350. };
  351.  
  352. struct facesubgroup2 {
  353.   unsigned short int ptype;
  354.   fract psize;
  355.   char count;
  356.   char filename[0];
  357. };
  358.  
  359. struct facesubgroup3 {
  360.   unsigned int ptype;
  361.   fract psize;
  362.   char count;
  363.   char filename[0];
  364. };
  365.  
  366. struct subgroup {
  367.   char subgroup[18];
  368. };
  369.  
  370. #define TXT_FLAGS    0b00000000000000111
  371. #define TXT_CHILD    0
  372. #define TXT_LIGHT    1
  373. #define TXT_DISAB    2
  374. #define TPT_FLAGS    0b00000000000111111
  375. #define TPT_RED        0
  376. #define TPT_GREEN    1
  377. #define TPT_BLUE    2
  378. #define TPT_SCALE    3
  379. #define TPT_UNUSE    4
  380. #define TPT_LUNUS    5
  381.  
  382. struct texture {
  383.   unsigned short int flags;
  384.   tform tform;
  385.   fract params[16];
  386.   char pflags[16];
  387.   char length;
  388.   char name[0];
  389. };
  390.  
  391. struct texture2 {
  392.   unsigned short int flags;
  393.   tform tform;
  394.   fract params[16];
  395.   char pflags[16];
  396.   char subgrp[18];
  397.   char length;
  398.   char name[0];
  399. };
  400.  
  401. struct texture3 {
  402.   unsigned short int flags;
  403.   tform tform;
  404.   fract params[16];
  405.   char pflags[16];
  406.   char subgrp[18];
  407.   char stname[18];
  408.   char length;
  409.   char name[0];
  410. };
  411.  
  412. struct texture4 {
  413.   unsigned short int flags;
  414.   tform tform;
  415.   fract params[16];
  416.   char pflags[16];
  417.   char subgrp[18];
  418.   char stname[18];
  419.   char label[18];
  420.   fract mixing;
  421.   char length;
  422.   char name[0];
  423. };
  424.  
  425. #define BRS_FLAGS    0x0F                    /*0b000001111 */
  426. #define BRS_COLOR    0
  427. #define BRS_REFLE    1
  428. #define BRS_FILTE    2
  429. #define BRS_ALTIT    3
  430. #define BRS_ENVRE    4
  431. #define BRS_SPECU    5
  432. #define BRS_HARDN    6
  433. #define BRS_ROUGH    7
  434. #define BRS_FOGLE    8
  435. #define BRS_SHINI    9
  436. #define BRS_BRIGH    10
  437. #define BRS_INDEX    11
  438. #define BRS_LIGHT    12
  439. #define BRW_FLAGS    0x7F                    /*0b011111111 */
  440. #define BRW_X        1
  441. #define BRW_Y        2
  442. #define BRW_CHILD    4
  443. #define BRW_REPEA    8
  444. #define BRW_FLIP    16
  445. #define BRW_INVER    32
  446. #define BRW_ZEROC    64
  447. #define BRW_DISAB    128
  448.  
  449. #if 0
  450. struct brush {
  451.   unsigned short int flags, wflags;
  452.   tform tform;
  453.   char length;
  454.   char name[0];
  455. };
  456.  
  457. #endif
  458.  
  459. struct brush2 {
  460.   unsigned short int flags, wflags;
  461.   tform tform;
  462.   unsigned short int fullscale, maxseq;
  463.   char length;
  464.   char name[0];
  465. };
  466.  
  467. struct brush3 {
  468.   unsigned short int flags, wflags;
  469.   tform tform;
  470.   unsigned short int fullscale, maxseq;
  471.   char subgrp[18];
  472.   char length;
  473.   char name[0];
  474. };
  475.  
  476. struct brush4 {
  477.   unsigned short int flags, wflags;
  478.   tform tform;
  479.   unsigned short int fullscale, maxseq;
  480.   char subgrp[18];
  481.   char stname[18];
  482.   char length;
  483.   char name[0];
  484. };
  485.  
  486. struct brush5 {
  487.   unsigned short int flags, wflags;
  488.   tform tform;
  489.   unsigned short int fullscale, maxseq;
  490.   char subgrp[18];
  491.   char stname[18];
  492.   char label[18];
  493.   fract mixing, foglo, foghi;
  494.   char length;
  495.   char name[0];
  496. };
  497.  
  498. /*
  499.  * tools
  500.  */
  501. static inline fract float2fract(float number);
  502. static inline float fract2float(fract number);
  503.  
  504. static inline fract float2fract(float number)
  505. {
  506.   if (number < 0)
  507.     return -(int)(-65536.0 * number + 0.5);
  508.   else
  509.     return (int)(65536.0 * number + 0.5);
  510. }
  511.  
  512. static inline float fract2float(fract number)
  513. {
  514.   return number / 65536.0;
  515. }
  516.  
  517. #endif
  518.